<template>
  <div>
    <h3>商品列表</h3>
    <my-list :list="list">
      <template #default="{ id }">
        <button @click="del(id)">删除</button>&nbsp;
        <button>编辑</button>
      </template>
    </my-list>
  </div>
</template>

<script>
export default {
  data () {
    return {
      list: [
        { id: 2, name: '瓜子' },
        { id: 3, name: '苹果' },
        { id: 5, name: '花生' }
      ]
    }
  },
  methods: {
    del (id) {
      console.log(id)
      this.list = this.list.filter(item => item.id != id)
    }
  }
}
</script>

<style></style>
